<h1>Listing contacts</h1>

<% link_to new_contact_path, :class => 'ui-state-default ui-corner-all dialog_link' do %>
	<span class="ui-icon ui-icon-plus"></span>New contact
<% end %>

<table>
  <tr class="ui-state-default">
    <th>Name</th>
    <th>Firstname</th>
    <th>User</th>
    <th>Company</th>
    <th>Mail</th>
    <th>Phone num</th>
    <th colspan="2"></th>
  </tr>

<% @contacts.each do |contact| %>
  <tr>
    <td><%=h contact.name %></td>
    <td><%=h contact.firstname %></td>
    <td><% if contact.user != nil %><%=h contact.user.login %><% end %></td>
    <td><% if contact.company != nil %><%=h contact.company.name %><% end %></td>
    <td><%=h contact.mail %></td>
    <td><%=h contact.phone_num %></td>
    <td>
    	<% link_to contact, :class => "ui-state-default ui-corner-all dialog_link" do %>
			<span class="ui-icon ui-icon-search"></span>View
		<% end %>
    </td>
    <td>
    	<% link_to contact, :confirm => 'Are you sure ?', :method => :delete, :class => "ui-state-error ui-corner-all dialog_link ui-state-hover" do %>
			<span class="ui-icon ui-icon-close"></span>Destroy
		<% end %>
	</td>
  </tr>
<% end %>
</table>